package com.xxkj.drugtraceability.net
import com.google.gson.Gson
import com.google.gson.TypeAdapter
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import retrofit2.Converter

/**
 * author: zhoujingjin
 * created on: 2022/2/28 10:23
 * description:
 */
class GsonRequestBodyDataConverter<T>(val gson: Gson,val adapter: TypeAdapter<T>): Converter<T, RequestBody> {
    private val MEDIA_TYPE = "application/x-www-form-urlencoded; charset=UTF-8".toMediaTypeOrNull()

    override fun convert(value: T): RequestBody {
        return (value as String)
            .toRequestBody(MEDIA_TYPE)
    }
}